<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta charset="utf-8" />
    <title>geosnap.analyze.transition &#8212; geosnap v0.3.1 Manual</title>
    <link rel="stylesheet" href="../_static/bootstrap-sphinx.css" type="text/css" />
    <link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
    <link rel="stylesheet" type="text/css" href="../_static/pysal-styles.css" />
    <script id="documentation_options" data-url_root="../" src="../_static/documentation_options.js"></script>
    <script src="../_static/jquery.js"></script>
    <script src="../_static/underscore.js"></script>
    <script src="../_static/doctools.js"></script>
    <script src="../_static/language_data.js"></script>
    <link rel="shortcut icon" href="../_static/geosnap.ico"/>
    <link rel="index" title="Index" href="../genindex.html" />
    <link rel="search" title="Search" href="../search.html" />
    <link rel="next" title="geosnap.harmonize.harmonize" href="geosnap.harmonize.harmonize.html" />
    <link rel="prev" title="geosnap.analyze.sequence" href="geosnap.analyze.sequence.html" />
<meta charset='utf-8'>
<meta http-equiv='X-UA-Compatible' content='IE=edge,chrome=1'>
<meta name='viewport' content='width=device-width, initial-scale=1.0, maximum-scale=1'>
<meta name="apple-mobile-web-app-capable" content="yes">
<script type="text/javascript" src="../_static/js/jquery-1.11.0.min.js "></script>
<script type="text/javascript" src="../_static/js/jquery-fix.js "></script>
<script type="text/javascript" src="../_static/bootstrap-3.3.7/js/bootstrap.min.js "></script>
<script type="text/javascript" src="../_static/bootstrap-sphinx.js "></script>

  </head><body>

  <div id="navbar" class="navbar navbar-default navbar-fixed-top">
    <div class="container">
      <div class="navbar-header">
        <!-- .btn-navbar is used as the toggle for collapsed navbar content -->
        <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".nav-collapse">
          <span class="icon-bar"></span>
          <span class="icon-bar"></span>
          <span class="icon-bar"></span>
        </button>
        <a class="navbar-brand" href="../index.html"><span><img src="../_static/geosnap.svg"></span>
          geosnap</a>
        <span class="navbar-text navbar-version pull-left"><b>0.3.1</b></span>
      </div>

        <div class="collapse navbar-collapse nav-collapse">
          <ul class="nav navbar-nav">
            
                <li><a href="../installation.html">Installation</a></li>
                <li><a href="../api.html">API</a></li>
                <li><a href="../data.html">Data</a></li>
                <li><a href="https://spatialucr.github.io/geosnap-guide/">User Guide</a></li>
                <li><a href="../references.html">References</a></li>
            
            
              <li class="dropdown globaltoc-container">
  <a role="button"
     id="dLabelGlobalToc"
     data-toggle="dropdown"
     data-target="#"
     href="../index.html">Site <b class="caret"></b></a>
  <ul class="dropdown-menu globaltoc"
      role="menu"
      aria-labelledby="dLabelGlobalToc"><p class="caption"><span class="caption-text">Contents:</span></p>
<ul class="current">
<li class="toctree-l1"><a class="reference internal" href="../installation.html">Installation</a><ul>
<li class="toctree-l2"><a class="reference internal" href="../installation.html#installing-a-released-version">Installing a released version</a></li>
<li class="toctree-l2"><a class="reference internal" href="../installation.html#installing-development-version">Installing development version</a></li>
</ul>
</li>
<li class="toctree-l1 current"><a class="reference internal" href="../api.html">API</a><ul class="current">
<li class="toctree-l2"><a class="reference internal" href="../api.html#io-module">IO Module</a></li>
<li class="toctree-l2"><a class="reference internal" href="../api.html#the-community-class">The Community Class</a></li>
<li class="toctree-l2 current"><a class="reference internal" href="../api.html#analyze-module">Analyze Module</a></li>
<li class="toctree-l2"><a class="reference internal" href="../api.html#harmonize-module">Harmonize Module</a></li>
<li class="toctree-l2"><a class="reference internal" href="../api.html#visualize-module">Visualize Module</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="../references.html">References</a></li>
<li class="toctree-l1"><a class="reference internal" href="../data.html">Data</a><ul>
<li class="toctree-l2"><a class="reference internal" href="../data.html#tabular-data">Tabular Data</a></li>
<li class="toctree-l2"><a class="reference internal" href="../data.html#geo-data">Geo Data</a></li>
</ul>
</li>
</ul>
</ul>
</li>
              
                <li class="dropdown">
  <a role="button"
     id="dLabelLocalToc"
     data-toggle="dropdown"
     data-target="#"
     href="#">Page <b class="caret"></b></a>
  <ul class="dropdown-menu localtoc"
      role="menu"
      aria-labelledby="dLabelLocalToc"><ul>
<li><a class="reference internal" href="#">geosnap.analyze.transition</a></li>
</ul>
</ul>
</li>
              
            
            
            
            
            
          </ul>

          
            
<form class="navbar-form navbar-right" action="../search.html" method="get">
 <div class="form-group">
  <input type="text" name="q" class="form-control" placeholder="Search" />
 </div>
  <input type="hidden" name="check_keywords" value="yes" />
  <input type="hidden" name="area" value="default" />
</form>
          
        </div>
    </div>
  </div>

<div class="container">
  <div class="row">
    <div class="body col-md-12 content" role="main">
      
  <div class="section" id="geosnap-analyze-transition">
<h1>geosnap.analyze.transition<a class="headerlink" href="#geosnap-analyze-transition" title="Permalink to this headline">¶</a></h1>
<dl class="function">
<dt id="geosnap.analyze.transition">
<code class="sig-prename descclassname">geosnap.analyze.</code><code class="sig-name descname">transition</code><span class="sig-paren">(</span><em class="sig-param">gdf</em>, <em class="sig-param">cluster_col</em>, <em class="sig-param">time_var='year'</em>, <em class="sig-param">id_var='geoid'</em>, <em class="sig-param">w_type=None</em>, <em class="sig-param">permutations=0</em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/geosnap/analyze/dynamics.html#transition"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#geosnap.analyze.transition" title="Permalink to this definition">¶</a></dt>
<dd><p>(Spatial) Markov approach to transitional dynamics of neighborhoods.</p>
<dl class="field-list">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><dl>
<dt><strong>gdf</strong><span class="classifier"><a class="reference external" href="https://geopandas.readthedocs.io/en/latest/reference/geopandas.GeoDataFrame.html#geopandas.GeoDataFrame" title="(in GeoPandas v0.7.0+39.g9b17975)"><code class="xref py py-obj docutils literal notranslate"><span class="pre">geopandas.GeoDataFrame</span></code></a> or <a class="reference external" href="https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.html#pandas.DataFrame" title="(in pandas v1.0.3)"><code class="xref py py-obj docutils literal notranslate"><span class="pre">pandas.DataFrame</span></code></a></span></dt><dd><p>Long-form geopandas.GeoDataFrame or pandas.DataFrame containing neighborhood
attributes with a column defining neighborhood clusters.</p>
</dd>
<dt><strong>cluster_col</strong><span class="classifier"><a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(in Python v3.8)"><code class="docutils literal notranslate"><span class="pre">str</span></code></a> or <a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(in Python v3.8)"><code class="docutils literal notranslate"><span class="pre">int</span></code></a></span></dt><dd><p>Column name for the neighborhood segmentation, such as
“ward”, “kmeans”, etc.</p>
</dd>
<dt><strong>time_var</strong><span class="classifier"><a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(in Python v3.8)"><code class="docutils literal notranslate"><span class="pre">str</span></code></a>, optional</span></dt><dd><p>Column defining time and or sequencing of the long-form data.
Default is “year”.</p>
</dd>
<dt><strong>id_var</strong><span class="classifier"><a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(in Python v3.8)"><code class="docutils literal notranslate"><span class="pre">str</span></code></a>, optional</span></dt><dd><p>Column identifying the unique id of spatial units.
Default is “geoid”.</p>
</dd>
<dt><strong>w_type</strong><span class="classifier"><a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(in Python v3.8)"><code class="docutils literal notranslate"><span class="pre">str</span></code></a>, optional</span></dt><dd><p>Type of spatial weights type (“rook”, “queen”, “knn” or
“kernel”) to be used for spatial structure. Default is
None, if non-spatial Markov transition rates are desired.</p>
</dd>
<dt><strong>permutations</strong><span class="classifier"><a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(in Python v3.8)"><code class="docutils literal notranslate"><span class="pre">int</span></code></a>, optional</span></dt><dd><p>number of permutations for use in randomization based
inference (the default is 0).</p>
</dd>
</dl>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><dl>
<dt><strong>mar</strong><span class="classifier"><a class="reference external" href="https://giddy.readthedocs.io/en/latest/generated/giddy.markov.Markov.html#giddy.markov.Markov" title="(in giddy v2.3.0)"><code class="xref py py-obj docutils literal notranslate"><span class="pre">giddy.markov.Markov</span></code></a> instance or <a class="reference external" href="https://giddy.readthedocs.io/en/latest/generated/giddy.markov.Spatial_Markov.html#giddy.markov.Spatial_Markov" title="(in giddy v2.3.0)"><code class="xref py py-obj docutils literal notranslate"><span class="pre">giddy.markov.Spatial_Markov</span></code></a></span></dt><dd><p>if w_type=None, a classic Markov instance is returned. 
if w_type is given, a Spatial_Markov instance is returned.</p>
</dd>
</dl>
</dd>
</dl>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">geosnap</span> <span class="kn">import</span> <span class="n">Community</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">columbus</span> <span class="o">=</span> <span class="n">Community</span><span class="o">.</span><span class="n">from_ltdb</span><span class="p">(</span><span class="n">msa_fips</span><span class="o">=</span><span class="s2">&quot;18140&quot;</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">columbus1</span> <span class="o">=</span> <span class="n">columbus</span><span class="o">.</span><span class="n">cluster</span><span class="p">(</span><span class="n">columns</span><span class="o">=</span><span class="p">[</span><span class="s1">&#39;median_household_income&#39;</span><span class="p">,</span>
<span class="gp">... </span><span class="s1">&#39;p_poverty_rate&#39;</span><span class="p">,</span> <span class="s1">&#39;p_edu_college_greater&#39;</span><span class="p">,</span> <span class="s1">&#39;p_unemployment_rate&#39;</span><span class="p">],</span>
<span class="gp">... </span><span class="n">method</span><span class="o">=</span><span class="s1">&#39;ward&#39;</span><span class="p">,</span> <span class="n">n_clusters</span><span class="o">=</span><span class="mi">6</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">gdf</span> <span class="o">=</span> <span class="n">columbus1</span><span class="o">.</span><span class="n">gdf</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">a</span> <span class="o">=</span> <span class="n">transition</span><span class="p">(</span><span class="n">gdf</span><span class="p">,</span> <span class="s2">&quot;ward&quot;</span><span class="p">,</span> <span class="n">w_type</span><span class="o">=</span><span class="s2">&quot;rook&quot;</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">a</span><span class="o">.</span><span class="n">p</span>
<span class="go">array([[0.79189189, 0.00540541, 0.0027027 , 0.13243243, 0.06216216,</span>
<span class="go">    0.00540541],</span>
<span class="go">   [0.0203252 , 0.75609756, 0.10569106, 0.11382114, 0.        ,</span>
<span class="go">    0.00406504],</span>
<span class="go">   [0.00917431, 0.20183486, 0.75229358, 0.01834862, 0.        ,</span>
<span class="go">    0.01834862],</span>
<span class="go">   [0.1959799 , 0.18341709, 0.00251256, 0.61809045, 0.        ,</span>
<span class="go">    0.        ],</span>
<span class="go">   [0.32307692, 0.        , 0.        , 0.        , 0.66153846,</span>
<span class="go">    0.01538462],</span>
<span class="go">   [0.09375   , 0.0625    , 0.        , 0.        , 0.        ,</span>
<span class="go">    0.84375   ]])</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">a</span><span class="o">.</span><span class="n">P</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span>
<span class="go">array([[0.82119205, 0.        , 0.        , 0.10927152, 0.06622517,</span>
<span class="go">    0.00331126],</span>
<span class="go">   [0.14285714, 0.57142857, 0.14285714, 0.14285714, 0.        ,</span>
<span class="go">    0.        ],</span>
<span class="go">   [0.5       , 0.        , 0.5       , 0.        , 0.        ,</span>
<span class="go">    0.        ],</span>
<span class="go">   [0.21428571, 0.14285714, 0.        , 0.64285714, 0.        ,</span>
<span class="go">    0.        ],</span>
<span class="go">   [0.18918919, 0.        , 0.        , 0.        , 0.78378378,</span>
<span class="go">    0.02702703],</span>
<span class="go">   [0.28571429, 0.        , 0.        , 0.        , 0.        ,</span>
<span class="go">    0.71428571]])</span>
</pre></div>
</div>
</dd></dl>

</div>


    </div>
      
  </div>
</div>
<footer class="footer">
  <div class="container">
    <p class="pull-right">
      <a href="#">Back to top</a>
      
        <br/>
        
<div id="sourcelink">
  <a href="../_sources/generated/geosnap.analyze.transition.rst.txt"
     rel="nofollow">Source</a>
</div>
      
    </p>
    <p>
        &copy; Copyright 2020, geosnap developers.<br/>
      Created using <a href="http://sphinx-doc.org/">Sphinx</a> 2.4.4.<br/>
    </p>
  </div>
</footer>
  </body>
</html>